<%--
 *  File:    CustClearRules.jsp
 *  @Author: banshang
 *  Date:    2010/07/23
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "COM";
 	String strTableName = "v_salesbehaviour";
	String privilegeCode = "E0521";    
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title>CustClearRules</title>
<PageFlow:CheckPageFlow pageName="p_custclearrules"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector details = (Vector)pageContext.getAttribute("details");
  	if(details == null)
  	{
  		details = new Vector();
  	}
%>



<script language="JavaScript" >
function page_summary(actionvalue,orderbyname){
  	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
 	 editform.action = "SalesBehavior.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}


function page_add(){
	 if(!checkForm(cform)) return;
	 
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}
function page_setproduct(id,umcode,prodcode,prodname){
	document.cform.prodid.value=id;
	document.cform.productname.value=prodname;
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}

</script>

</head>
<body>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_custclearrules">
	<input type="hidden" name="actionname">
	<custom:hidden property="opt"/>
    <tr> 
	    <td> 
	      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
	         <tr class="deepblue-left" >
			  <td width="2%" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
	          <td class="title_center" width="5%"><%= label.getLabelName("L_Sequences") %>&nbsp;<span class='red'>*</span></td>
	          <td class="title_center" width="20%"><%= label.getLabelName("L_SalesChannelCategory") %>&nbsp;<span class='red'>*</span></td>
	          <td class="title_center" width="*"><%= label.getLabelName("L_SQL") %>&nbsp;<span class='red'>*</span></td>
	        </tr>
	        <%
            	int i = 0;
             	String strClassType = new String();
          	%>
	         <logic:iterate id="onerow" collection="<%= details %>" indexId="idx">
	           	<%
	            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
	            	if(i%2 == 1)
	            	{
	              		strClassType = "td-listrom";
	            	}else{
	              		strClassType = "";
	            	}
	            	i++;
	          	%>
	          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
	          		<td class="title_center" >
	              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("customercleanrulesid") )%>" class="checkbox">
	            	</td>
	            	<td class="title_center">
	            		<custom:write name="onerow" property="sequence" nbsp="true"/>
	            	</td>
	            	<td class="title_center">
	            		<custom:write name="onerow" property="orgname" nbsp="true"/>
	            	</td>
					<td>
	            		<custom:write name="onerow" property="sqldesc" nbsp="true"/>
	            	</td>
	     		 </tr>
	     	 </logic:iterate>
	     	 <tr class="none">
	           <td>&nbsp;</td>
	           <td>
	           	<custom:text property="sequence" command="signlessinteger" label="L_Sequences" size="5"/>
	           </td>
	           <td>
			    <custom:select optionInnerTextKey="orgname" optionsName="allsaleschannels" property="saleschannel" optionValueKey="orgid" defaultValue="--------" defaultValueCost=" " command="notnull" label="L_SalesChannelCategory"/>
			   </td>
	           <td >
	           	<custom:textarea property="sqldesc" rows="3" style="width:100%;" command="notnull" label="L_SQL"/>
	           </td>
		     </tr>
	      </table>
	      <table width="100%" cellspacing="0" cellpadding="0">
	        <tr> 
	          <td class="summary_top"></td>
	        </tr>
	        <tr>
			     <td class="td_center">
					<a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
					<%if(details.size() >0 ){%>
					<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
					<%} %>
				 </td>
			</tr>
	      </table>
	    </td>
  </tr>
  </form>
</table>
</body>
</html>